	{extend name="public/base" /}
	{block name="style"}
	<link rel="stylesheet" href="__PUBLIC__/admin/material/css/index.css?v=20221110&times=111" />
	<link rel="stylesheet" href="__PUBLIC__/admin/material/css/iconfont.css" />
	{include file="material/_ali_icon" /}
	<style>
	.main-box-body .navs .active {
		background: azure;
		color: #03a9f4;
		border: 1px solid #03a9f4;
		border-radius: 5px;
	}
	a {
		color: #777;
		text-decoration:none;
	}
	a:hover { text-decoration :none}
	.table tbody>tr>td {padding: 0px 8px;}
	.table-hover>tbody>tr:nth-child(odd){background-color: #f9f9f9;}
	.table-responsive {
		min-height: 470px;
	}
	textarea.form-control {
		height: 52px;
		min-height: auto;
	}
	em{
		color: red;
	}
	.row-selected,.check-all{
		display: inline-block;
    	vertical-align: middle;
		margin-top: -3px!important;
	}
	.line{
		position: absolute;
		height: 108%;
		width: 1px;
		background-color: #d5d5d5;
		top: 0;
		right: 115px;
	}
	</style>
	{/block}
	{block name="body"}
	<div class="main-box clearfix">
		<header class="main-box-header clearfix">
			<div class="pull-right">
				<!-- <button type="button" class="btn btn-primary" id="createUrl">
					<i class="fa fa-plus"></i> 添加素材 <span class="caret"></span>
				</button> -->
				<button type="button" class="btn btn-primary" id="add_my_one">
					<i class="fa fa-plus"></i> 添加素材 <span class="caret"></span>
				</button>
				<button class="btn btn-danger ajax-post confirm" url="{:url('del_my')}" target-form="ids">删 除</button>
			</div>
			<div class="row">
				<form method="get">
					{include file="material/_date" /}
					<div class="col-sm-12 col-md-4 col-lg-3">
						<input type="text" class="form-control" name="keyword" value="{$keyword|default=''}" placeholder="请输入关键字搜索">
					</div>
					<input type="hidden" name="platform_ids" value="{:input('get.platform_ids')}">
					<input type="hidden" name="type" value="{:input('get.type')}">
					<div class="col-sm-12 col-md-4">
						<button class="btn btn-primary" type="submit">搜索</button>
					</div>
					
				</form>
			</div>
		</header>
		<div class="main-box-body clearfix">
			<!-- 搜索相关 -->
			{include file="material/_search" /}
			<div id="" class="clear"></div>
			<div class="table-responsive clearfix">
				<div class="table-responsive clearfix">
					<table class="table table-hover table-bordered">
						<thead>
							<tr>
								<th width="30"><input class="checkbox check-all" type="checkbox"></th>
								<th width="42%"><!--广告文案-->{$menu_name|default="旧文案"}</th>
								
								<th width="446px"><!--广告文案-->{$menu_name|default="修改文案"}</th>
								<!-- <th>平台/频道/分类/工号</th>
								<th width="10%">标签</th>-->
								<th width="40">书名</th> 
								<th width="45">操作</th>
								<th width="25">复制</th>
							</tr>
						</thead>
						<tbody>
							{empty name="list"}
							<tr><td colspan="9" align="center">暂无数据</td></tr>
							{/empty}
							{volist name="list" id="vo"}
							<tr>
								<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$vo['id']}"></td>
								<td class="toolTip" style="display: flex;align-items: center;height: 42px;">
									<div style="font-size: 13px;margin-right:5px">
										{$vo['num']}
									</div>
									<div class="example" style='font-size: 18px;  color: #833f39' title2="{$vo.content}">
										{$vo.content_old|default="无"}
									</div>
								</td>
								

								<td class="toolTip">
									<div class="form-group">

										<div class="col-lg-12" style="padding: 2px;position: relative;">
											<!-- <textarea class="form-control" " id="content_{$vo['id']}" placeholder="" style="resize:auto;font-size: 18px;">{$vo.content}</textarea> -->
											<input class="form-control numChange"type="text" id="content_{$vo['id']}" style="font-size: 18px;{if $vo['is_edit']==2}color:#b92a1db8;{/if}" value="{$vo.content}">
											<i class="line"></i>

										</div>
									</div>
								</td>
								<!-- <td>{$vo.platform_ids_zh} / {$vo.channel_zh} / {$vo.category_id_zh} | {$vo.uid} </td>
								<td>{$vo.tag_ids_zh}</td> -->
								<td>{$vo.book_id_zh}</td>
								<td>
									<a href="JavaScript:;" onclick="editContent(this, {$vo['id']})" data-json='{:json_encode($vo)}'><i class="fa fa-edit"></i> 保存</a>
									<!-- <a href="{:url('del_my',array('id'=>$vo['id']))}" class="ajax-get confirm"><i class="fa fa-times"></i> 删除</a>-->
									
								</td>
								<td>
									<div onclick="copyContent(this, {$vo['id']})" class="copy">
										<span class="iconfont icon-copy"></span>
										复制
									</div>

									<a href="JavaScript:;" onclick="editreferral(this, 'close_rule')" data-json='{:json_encode($vo)}'><i class="fa fa-edit"></i> 修改</a> 
								
								</td>
							</tr>
							{/volist}
							
						</tbody>
					</table>
				</div>
				{$page}
			</div>
		</div>
	</div>

	<div class="modal fade" id="create-referral-link-modal">
		<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
				<span style="font-size: 20px;"><span id="referralname">添加</span></span>
			</div>
			<div class="modal-body">
				<div data-bind="visible: loading" class="loading-panel" style="display: none;">
					<i class="fa fa-spin fa-spinner"></i>
				</div>
				<form class="form-horizontal modelform">
					{include file="material/_from" /}
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" id="createreferral" class="btn btn-primary ">提交</button>
			</div>
		</div>
	</div>
	</div>

	{include file="adsmaterialbook/_from" /}
	{/block}
	{block name="script"}
	<script type="text/javascript" src="__PUBLIC__/plugs/layer/layer.js"></script>
	<script type="text/javascript">
		function copyContent(elem, id){
			let text = $(elem).parent().siblings('.toolTip').children('.example').text().trim()
			var oInput = document.createElement('input');//创建一个input标签
			oInput.value = text;//设置value属性
			document.body.appendChild(oInput);//挂载到body下面
			oInput.select(); // 选择对象
			document.execCommand("Copy"); // 执行浏览器复制命令
			oInput.className = 'oInput';
			oInput.style.display='none';
			layer.msg('复制成功');
		}

	</script>
	<!-- <script src="__PUBLIC__/plugs/moment/moment.min.js"></script>
	<script src="__PUBLIC__/plugs/moment/zh-cn.js"></script> -->
	<script type="text/javascript">

	$(function() {
		$('#add_my_one').on('click',function(){
			var url = "{:url('add_my_one')}";
			$.ajax({
				type: "POST",
				url: url,
				data:{"platform_ids":{$platform_id},"type":{$typeid}},
				dataType: "json",
				success: function(data){
					if(data.code==1){
						updateAlert(data.msg, 'success');
						setTimeout(function() {	
							window.location.reload();
						}, 100);
					}else{
						updateAlert("添加，"+data.msg, 'danger');
					}
				},
				error : function(e){
					console.log(e.status);
					console.log(e.responseText);
				}
			})
		});
		$('#add_one').on('click',function(){
			var $modal = $('#create-referral-link-modal');
			$modal.on('shown.bs.modal', function () {
			});	
			$modal.modal({backdrop: 'static', keyboard: false})
		});
		$("#createreferral").on('click',function(){
			var data = $('.modelform').serializeJson();
			if ( data['book_id'] == undefined) {
				updateAlert("书名不能为空", 'danger');
				return false;
			}
			if (data['content'].length==0) {
				updateAlert("不能为空", 'danger');
				return false;
			}
			var url = "{:url('add_my')}";
			$.ajax({
				type: "POST",
				url: url,
				data:data,
				dataType: "json",
				success: function(data){
					if(data.code==1){
						updateAlert(data.msg, 'success');
						setTimeout(function() {	
							window.location.reload();
						}, 100);
					}else{
						updateAlert("添加，"+data.msg, 'danger');
					}
				},
				error : function(e){
					console.log(e.status);
					console.log(e.responseText);
				}
			})
		});
	});

	function editContent(ee, id){
		$.ajax({
			type: "POST",
			url: '{:url('editMyContent')}',
			data:{id:id, content:$('#content_'+id).val()},
			dataType: "json",
			success: function(data){
				if(data.code==1){
					updateAlert(data.msg, 'success');
					setTimeout(function() {	
						window.location.reload();
					}, 100);
				}else{
					updateAlert("添加，"+data.msg, 'danger');
				}
			},
			error : function(e){
				console.log(e.status);
				console.log(e.responseText);
			}
		})
	}

	$(".numChange").on('input',function(e){
		let textNum = $(this).val().length;
		if(textNum>35){
			layer.msg('请不要超过35个字！',{icon:5,time:2000});
			$(this).val($(this).val().substr(0,35))
		}

	});
</script>
{include file="material/pub_footer"}
{/block}